
//添加城市
function addCity() {
	var _city = $("#addCity_city").val();
	var _province = $("#addCity_province").val();
	$.post(ctx+"/community/add.city",{province:_province,city:_city},function(data){
		if(data&&data.status==200){
			alert(data.message);
		}
	});
}

//显示小区信息信息
function showCommunityDetail(_city) {
	$.post(ctx+"/community/get",{city:_city},function(data){
		if(data&&data.status==200){
			$("#cityDetailDiv").show();
			var configCity=data.result;
			$("#cityDetail_city").html(configCity.name);
			$("#cityDetailPanel").html("");
			
			for(var i=0;i<configCity.county.length;i++){
				var configCounty=configCity.county[i];
				$("#cityDetailPanel").append("<h4>"+configCounty.name+"</h4>");
				for(var j=0;j<configCounty.community.length;j++){
					var community=configCounty.community[j];
					$("#cityDetailPanel").append("<li>"+community+"</li>")
				}
			}
		}else{
			alert(data.message)
		}
	});
}

//显示小区面板
function showCommunityDiv(_city) {
	$.post(ctx+"/community/get",{city:_city},function(data){
		if(data&&data.status==200){
			$("#addCommunityDiv").show();
			var configCity=data.result;
			$("#addCommunity_city").html(configCity.name);
			$("#addCommunity_countySelect").empty(); 
			
			for(var i=0;i<configCity.county.length;i++){
				var configCounty=configCity.county[i];
				$("#addCommunity_countySelect").append("<option value="+configCounty.name+">"+configCounty.name+"</option>"); 
			}
		}else{
			alert(data.message)
		}
	});
}

//添加区县
function addCounty() {
	var _city= $("#addCommunity_city").text();
	var _county= $("#addCommunity_county").val();
	$.post(ctx+"/community/add.county",{city:_city,county:_county},function(data){
		if(data/*&&data.status==200*/){
			alert(data.message);
		}
	});
}

//添加小区
function addCommunity() {
	var _city= $("#addCommunity_city").text();
	var _county= $("#addCommunity_countySelect").val();
	var _community= $("#addCommunity_community").val();
	$.post(ctx+"/community/add.community",{city:_city,county:_county,community:_community},function(data){
		if(data/*&&data.status==200*/){
			alert(data.message);
		}
	});
}

//删除城市配置
function deleteCity(_city) {
	$.post(ctx+"/community/delete.city",{city:_city},function(data){
		if(data/*&&data.status==200*/){
			alert(data.message);
		}
	});
}